//
//  MytenderSecondViewController.m
//  LineMoney
//
//  Created by 尹宁 on 16/7/15.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "MytenderSecondViewController.h"
#import "CompleteTableViewCell.h"
#import "MyTenderBottomView.h"
#import "MyTenderSecondCell.h"
#import "MyTenderThreeViewController.h"

@interface MytenderSecondViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *listArr;
@property (nonatomic, strong) MyTenderBottomView *bottomView;
@property (nonatomic, strong) UITableView *tableView2;

@property (nonatomic, assign) NSInteger i;
@end

@implementation MytenderSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"我的招标";
    self.i = 0;
    [self initTableView];
    [self initTableView2];

    [self creatBottomView];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
}


- (void)creatBottomView
{
    
    self.bottomView = [[[NSBundle mainBundle] loadNibNamed:@"MyTenderBottomView" owner:nil options:nil] lastObject];
    _bottomView.frame = CGRectMake(0, KSCREENHEIGHT - 45 - 64, KSCREENWIDTH, 45 + 64);
    [self.view addSubview:_bottomView];
    [[_bottomView.leftBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    [[_bottomView.rightBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        MyTenderThreeViewController *threeVC = [[MyTenderThreeViewController alloc]init];
        threeVC.i = _i;
        [self.navigationController pushViewController:threeVC animated:YES];
    }];
    
}
- (void)initTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, 126) style:UITableViewStylePlain];
//    [self.view addSubview:_tableView];
    _tableView.rowHeight = KSCREENHEIGHT / 6.3;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];// 如果没有数据下方不显示分割线
    [_tableView registerNib:[UINib nibWithNibName:@"CompleteTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}

- (void)initTableView2
{
    self.tableView2 = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, KSCREENHEIGHT - 45) style:UITableViewStylePlain];
    [self.view addSubview:_tableView2];
    _tableView2.rowHeight = KSCREENHEIGHT / 6.3;
    _tableView2.delegate = self;
    _tableView2.dataSource = self;
    [_tableView2 setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];// 如果没有数据下方不显示分割线
    [_tableView2 registerNib:[UINib nibWithNibName:@"CompleteTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    [_tableView2 registerNib:[UINib nibWithNibName:@"MyTenderSecondCell" bundle:nil] forCellReuseIdentifier:@"cell1"];
    _tableView2.tableHeaderView = _tableView;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _tableView) {
        
        CompleteTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];// 去掉点击之后的阴影
        cell.MoreImage.hidden = YES;
        return cell;
    }else
    {
    
        MyTenderSecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];// 去掉点击之后的阴影
        [[[cell.Btn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:cell.rac_prepareForReuseSignal] subscribeNext:^(id x) {
           
            if (cell.isSelect == YES) {
                self.i--;
            }else{
                _i++;
            }
            [cell selectImg];
            
        }];
        if (indexPath.row == 0) {

            [cell rowEqualOne];
        }
        return cell;
    
    }
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (tableView == _tableView) {
        return 1;
    }
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == _tableView) {
        return 1;
    }
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _tableView) {
        return 126;
    }
    return 42;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 15;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
